<?php
class p_video_premium extends Model
{
    public static function getTableName()
    {
        return 'p_video_premium';
    }

    public function getPrimaryKey()
    {
        return array('video_id');
    }

    public function set($obj)
    {
        $this->video_id = $obj->id ? $obj->id : ''; 
        $this->ppv_flag = !empty($obj->premium_items) && in_array('ppv',$obj->premium_items) ? 1 : 0;
        $this->subscription_flag =!empty($obj->premium_items) &&  in_array('subscription',$obj->premium_items) ? 1  : 0; 
    }

    public function insert($obj)
    {
        return Model::$dbo['w']->insert($obj);
    }

    public function update($obj)
    {
        return Model::$dbo['w']->save($obj);
    }
}
?>
